
package com.eshop.we.business.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.baomidou.mybatisplus.plugins.Page;
import com.eshop.we.business.BaseBusinessImpl;
import com.eshop.we.business.LeaseBusiness;
import com.eshop.we.lease.api.LeaseService;
import com.eshop.we.lease.dto.LeaseDto;
import com.eshop.we.lease.entity.Lease;
import com.eshop.we.school.api.SchoolService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangzhanguo
 * @create 2018-06-04 15:31
 **/
@Service
public class LeaseBusinessImpl extends BaseBusinessImpl<Lease,LeaseService> implements LeaseBusiness{
    @Reference
    private LeaseService leaseService;

    @Reference
    private SchoolService schoolService;

    @Override
    public Page<LeaseDto> selectSelfPage(Page<LeaseDto> page, Integer schoolId) {
        return leaseService.selectBySchoolIdsPage(page,new ArrayList<Integer>(){{
            add(schoolId);
        }});
    }

    @Override
    public Page<LeaseDto> selectNearPage(Page<LeaseDto> page, String lng, String lat, Integer distance) {
        //查询附近的学校列表
        List<Integer> schoolIds = schoolService.searchNearSchools( lng,  lat,  distance);
        //根据学校id查询租书信息
        return leaseService.selectBySchoolIdsPage(page,schoolIds);
    }
}

